
chrome.extension.onRequest.addListener(
  function(request, sender, sendResponse) {
      console.log(sender.tab ?
                "from a content script:" + sender.tab.url :
                "from the extension");
      if (request.query == "username") {
          var shanbay = new ShanbayAPI();

          shanbay.getUser(
            function(user) {
                console.log("get user: " + user);
                sendResponse({ username: user });
            }
          );
      }
  });